home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Demos
/
Bowers Development
/
AppMaker 2.0b5
/
Examples
/
TCL
/
AMReminder
/
AMReminderData.cp
< prev
next >
Wrap
Text File
|
1996-03-19
|
4KB
|
159 lines
// AMReminderData.cp -- data access methods
// Created 01/01/95 12:01 PM by AppMaker
// This module contains data structures to access the data in your
// document's file(s). The intent is to isolate the details of the
// data representation into this module and to provide accessor
// functions for reading/writing logical pieces of the data.
// For your application, you will probably rewrite most of this.
// This module will not be regenerated by AppMaker unless you delete it.
#include <CDocument.h>
#include "AMReminderData.h"
extern OSType gSignature; /* The application's signature */
/*----------*/
void CAMReminderData::IAMReminderData (CDocument *theDocument)
{
inherited::IDataFile ();
hasFile = FALSE;
itsDocument = theDocument;
// your application-specific initialization
itsData = NULL;
} /* IAMReminderData */
/*----------*/
void CAMReminderData::Dispose (void)
{
DisposeData ();
ForgetObject (this);
} /* Dispose */
/*----------*/
void CAMReminderData::OpenData (SignedByte permission)
{
Open (permission);
hasFile = TRUE;
ReadData ();
} /* OpenData */
/*----------*/
void CAMReminderData::Close (void)
{
inherited::Close ();
hasFile = FALSE;
// don't DisposeData because data may be needed by SaveAs
} /* Close */
/*----------*/
Boolean CAMReminderData::Save (void)
{
if (hasFile) {
return (WriteData ());
} else {
// shouldn't be called in this case
return (FALSE);
}
} /* Save */
/*----------*/
Boolean CAMReminderData::SaveAs (SFReply *macSFReply)
{
// If all of your data is in memory, then just close the current file
// create and open a file, then save your data into the new file
//
// If some of your data is in the current file and not in memory,
// you may have to create and open the new file,
// copy data from the current file to the new file,
// close the current file,
// then save your data into the new file
OSErr ignoreErr;
if (hasFile) {
Close ();
}
SFSpecify (macSFReply);
ignoreErr = HDelete (volNum, dirID, name); // in case already exists
CreateNew (gSignature, kFileType);
Open (fsRdWrPerm);
hasFile = TRUE;
return (Save ());
} /* SaveAs */
/*----------*/
void CAMReminderData::Revert (void)
{
DisposeData ();
if (hasFile) {
ReadData ();
}
} /* Revert */
// The next few methods are for transferring data between the
// data file and your internal data structures, and for disposing
// your data structures. They are called by Open, Close, etc.
// Replace their bodies with whatever is suitable for your application
// define internal data structures to describe the file format:
typedef struct {
short stuff;
} fileData;
/*----------*/
void CAMReminderData::ReadData (void)
{
itsData = ReadAll ();
} /* ReadData */
/*----------*/
Boolean CAMReminderData::WriteData (void)
{
WriteAll (itsData);
return (TRUE);
} /* WriteData */
/*----------*/
void CAMReminderData::DisposeData (void)
{
if (itsData != NULL) {
DisposHandle (itsData);
itsData = NULL;
}
} /* DisposeData */
// The remaining methods are for accessing your data as logical chunks.
// These are just models for your own accessor functions;
// they aren't called by any AppMaker-generated code.
// Replace them with whatever is suitable for your application.
/*----------*/
void CAMReminderData::GetAMReminder (void)
{
} /* GetAMReminder */
/*----------*/
void CAMReminderData::PutAMReminder (void)
{
} /* PutAMReminder */
/*----------*/
void CAMReminderData::AddAMReminder (void)
{
} /* AddAMReminder */
/*----------*/
void CAMReminderData::DeleteAMReminder (void)
{
} /* DeleteAMReminder */
/* AMReminderData.cp */